<!--
 * @Description: 
 * @Version: 2.0
 * @Autor: snzo.chen
 * @Date: 2023-11-22 15:28:20
 * @LastEditors: snzo.chen
 * @LastEditTime: 2023-12-11 13:33:23
-->
<template>
  <div class="action-table">
    <a-space>
      <template v-if="showBack">
        <a-button :icon="h(LeftOutlined)" @click="backHistory"></a-button>
      </template>
      <template v-if="showAdd">
        <a-button type="primary" @click="$emit('addRow')">添加</a-button>
      </template>
      <slot></slot>
    </a-space>
  </div>
</template>
<script lang="ts" setup>
import { h } from "vue";
import { LeftOutlined } from "@ant-design/icons-vue";
import { useRouter } from "vue-router";

defineOptions({
  name: "ActionTable",
});
defineProps({
  showBack: {
    type: Boolean,
    default: true,
  },
  showAdd: {
    type: Boolean,
    default: true,
  },
});
const router = useRouter();
const backHistory = () => {
  router.go(-1);
};
</script>
<style lang="less" scoped>
.action-table {
  display: flex;
  flex-direction: row;
  margin-bottom: 20px;
}
</style>
